package com.glsc.ngateway.platform.controller.costallocation;

import com.glsc.ngateway.common.api.platform.resp.PlatformResponse;
import com.glsc.ngateway.platform.domain.costallocation.BusiSystemInfo;
import com.glsc.ngateway.platform.domain.costallocation.HisBusiSystemInfo;
import com.glsc.ngateway.platform.dto.BusiSystemInfoQueryDto;
import com.glsc.ngateway.platform.service.costallocation.HisBusiSystemInfoService;
import com.glsc.ngateway.platform.utils.JsonTool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/**
 * @author guoj
 * @description: 成本分摊-历史系统信息
 * @date 2024/7/18 13:43
 */
@RestController
@RequestMapping("/hisbusisystemInfo")
@Api(value = "HisBusiSystemInfoController", tags = {"历史系统信息"})
public class HisBusiSystemInfoController {
    @Autowired
    private HisBusiSystemInfoService hisBusiSystemInfoService;

    @PostMapping("/listpage")
    @ApiOperation(value = "查询分页")
    public PlatformResponse<Page<HisBusiSystemInfo>> listpage(@ApiParam(value = "查询条件") @RequestBody BusiSystemInfoQueryDto busiSystemInfoQueryDto) {
        return PlatformResponse.successData(hisBusiSystemInfoService.findPage(busiSystemInfoQueryDto));
    }

    @GetMapping("/compareDifferentPoint")
    @ApiOperation(value = "对比历史应用详情不同点")
    public PlatformResponse<?> compareDifferentPoint(@ApiParam(value = "左侧id") @RequestParam(value = "leftId") Long leftId,
                                                     @ApiParam(value = "右侧id") @RequestParam(value = "rightId") Long rightId) {
        return PlatformResponse.successData(hisBusiSystemInfoService.compareDifferentPoint(leftId,rightId));
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除一条流水")
    public PlatformResponse<?> delete(@RequestBody String idParam) {
        Long id = JsonTool.parseJsonId(idParam);
        if (id == null) {
            return PlatformResponse.failedMsg("id不能为空");
        }
        hisBusiSystemInfoService.delete(id);
        return PlatformResponse.successMsg("删除成功");
    }
}
